package com.partvoyage.server.service.wikipedia;

import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.partvoyage.client.service.wikipedia.WikipediaService;
import com.partvoyage.server.service.geoname.GeonameWebService;
import com.partvoyage.server.service.geoname.exception.GeonameServiceException;
import com.partvoyage.shared.GeonameWikiPediaBean;

/**
 * The server side implementation of the RPC service.
 */
@SuppressWarnings("serial")
public class WikipediaServiceImpl extends RemoteServiceServlet implements
		WikipediaService {
	public List<GeonameWikiPediaBean> getGeonameWikiPediaBean(Double latitude,
			Double longitude) throws GeonameServiceException {
		if (latitude == null || longitude == null) {
			throw new GeonameServiceException(
					"latitude or/and longitude can't be null");
		}
		// TODO gestion cache
		List<GeonameWikiPediaBean> geonameWikiPediaBean = null;
		// GeonameCache.getGeonameWikiPediaBeanListFromCache(
		// latitude, longitude, radius);
		if (geonameWikiPediaBean == null) {
			// we get the data
			geonameWikiPediaBean = GeonameWebService.getInstance()
					.getGeonameWikiPediaBean(latitude, longitude);
			// we add it in cache
			// TODO

		}
		return geonameWikiPediaBean;
	}

}
